﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using HeartLess.LevelData;
using HeartLess.Core;
using HeartLess.Managers;

namespace HeartLess.GameObjects
{
    class HealthModifier : Item
    {
        private Core.Animation _animation;
        private Single _healthDelta;

        private Player _target;

        public HealthModifier(Player target, Point location, Single healthDelta)
            : base(location)
        {
            Texture2D animationTexture = AssetManager.GetAnimationTexture(AssetManager.ANIMATIONS.HEALTH_MODIFIER);
            _animation = new Animation(animationTexture, 32, 60);
            _animation.Location = this.Location;

            _target = target;
            _healthDelta = healthDelta;
        }

        public override void Update(GameTime gameTime)
        {
            _animation.Update(gameTime);

            base.Update(gameTime);
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            _animation.Draw(spriteBatch);
        }

        protected override void handleCollision(CollidableGameObject collidedObject)
        {
            if (collidedObject == _target)
            {
                _target.AddHealth(_healthDelta);
                Dead = true;
            }
        }
    }
}
